<template>
  <div>
    <el-tabs v-model="activeName" >
      <el-tab-pane label="消息推送" name="AllContent" v-if="this.adminUser">
        <AllContent></AllContent>
      </el-tab-pane>
      <el-tab-pane label="未读消息" name="NoReadContent" v-if="this.personal">
        <NoReadContent></NoReadContent>
      </el-tab-pane>
      <el-tab-pane label="已读消息" name="ReadContent" v-if="this.personal">
        <ReadContent></ReadContent>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import NoReadContent from '../../components/sys/SysCfg/NoReadContent'
  import ReadContent from '../../components/sys/SysCfg/ReadContent'
  import AllContent from '../../components/sys/SysCfg/AllContent'
  export default {
    name: 'SysCfg',
    data(){
      return{
        activeName:'',
        user:JSON.parse(window.sessionStorage.getItem('user')),
        adminUser:false,
        personal:false
      }
    },
    mounted () {
      this.init();
    },
    methods: {

      init(){
        this.user.roles.forEach((temp, index) => {
          // 找到当前点击的行，把动态获取到的数据赋值进去
          if (temp.name==='ROLE_admin') {
            this.adminUser=true
          }else{
            this.personal=true
          }
        });
        this.user.roles[0].name==='ROLE_admin'

        if(this.user.roles[0].name==='ROLE_personal'){
          this.activeName='NoReadContent'
        }else{
          this.activeName='AllContent'
        }
      }
    },
    components:{
      NoReadContent,
      ReadContent,
      AllContent
    }
  }
</script>

<style scoped>
</style>
